<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
var a =[2,8,3,6,1]
for (var i=0;i<=a.length-1;i++){
    for(var b =0;b<=a.length-1-i;b++){
        //内部交换2个变量的值
        if (a[b]>a[b+1]){
            var c=a[b];
            a[b]=a[b+1]
            a[b+1]=c;
         }
       }
    }console.log(a);
      
        
    </script>
</body>
</html>